import type * as T from './type'
import http from '@/utils/http'

export type * from './type'

/**
 * 菜单树
 * @param query
 */
export function treeMenu(query: T.MenuQuery) {
  return http.post<T.MenuResp[]>(`/system/menu/tree`, query)
}

/**
 * 菜单详情
 * @param id
 */
export function getMenu(id: string) {
  return http.get<T.MenuResp>(`/system/menu/detail/${id}`)
}

/**
 * 新增菜单
 * @param data
 */
export function addMenu(data: any) {
  return http.post<boolean>(`/system/menu/create`, data)
}

/**
 * 修改菜单
 * @param data
 * @param id
 */
export function updateMenu(data: any, id: string) {
  return http.put(`/system/menu/update/${id}`, data)
}

/**
 * 删除菜单
 * @param id
 */
export function deleteMenu(id: string) {
  return http.del(`/system/menu/delete/${id}`)
}

/**
 * 清除菜单缓存
 */
export function clearMenuCache() {
  return http.del(`/system/menu/cache/clear`)
}
